bpf: verifier: Allocate idmap scratch in verifier env
authorLorenz Bauer <lmb@cloudflare.com>
Thu, 29 Apr 2021 13:46:56 +0000 (14:46 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Tue, 3 Aug 2021 05:50:50 +0000 (06:50 +0100)
commit075e347cb951d67b0c48c7bd7b24449cc78a186e
tree41ead344fce0811a80b5e05e4f179bd4992331c1
parenta5daf57abef7beec8c5322aa4b2e6a226eff13ee
bpf: verifier: Allocate idmap scratch in verifier env

commit c9e73e3d2b1eb1ea7ff068e05007eec3bd8ef1c9 upstream.

func_states_equal makes a very short lived allocation for idmap,
probably because it's too large to fit on the stack. However the
function is called quite often, leading to a lot of alloc / free
churn. Replace the temporary allocation with dedicated scratch
space in struct bpf_verifier_env.

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Edward Cree <ecree.xilinx@gmail.com>
Link: https://lore.kernel.org/bpf/20210429134656.122225-4-lmb@cloudflare.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name bpf-verifier-allocate-idmap-scratch-in-verifier-env.patch
include/linux/bpf_verifier.h
kernel/bpf/verifier.c